import React from "react";
import { withState } from "../context";
import Title from "./Title";

const CreditOpinion = (props) => {
    const { state, getApis } = props;
    const { name, widgetName, items, gitApis } = state;
    return <div><Title />
        <div>Credit Opinion - {name} - {widgetName}</div>
        <div>
            {
                items && items.map(i => <div key={i.desc}>{i.desc}</div>)
            }
        </div>
        <div>
            <button onClick={getApis}>Fetch git apis</button>
            <div>
                {
                    gitApis && Object.getOwnPropertyNames(gitApis).map(name => {
                        return <p key={name}>{name}:{gitApis[name]}</p>
                    })
                }
            </div>
        </div>
    </div>
}

export default withState(CreditOpinion);